Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
TypeScript package which smartly trims and strips indentation from multi-line strings
The ts-dedent package is a utility designed to remove indentation from multi-line template strings in TypeScript and JavaScript. This is particularly useful when working with code that needs to be displayed to the user or when dealing with strings that should not have additional leading whitespace that is typically introduced by code formatting in source files.
Dedentation of template strings
This feature allows you to normalize the indentation of multi-line strings to enhance readability and maintain consistent formatting. The dedent function automatically adjusts the indentation based on the least indented line in the template string.
import dedent from 'ts-dedent';
const text = dedent`
This is a text
with inconsistent
indentation.`;
console.log(text); // Outputs:
// This is a text
// with inconsistent
// indentation.
Similar to ts-dedent, the dedent package is also aimed at removing excess indentation from multi-line strings. It works in a similar manner but does not specifically target TypeScript, making ts-dedent potentially more suitable for projects that are using TypeScript.
The strip-indent package removes leading whitespace from each line in a string. It differs from ts-dedent in that it does not consider the relative indentation levels between lines, but simply strips the common leading whitespace from all lines.
TypeScript package which smartly trims and strips indentation from multi-line strings.
import dedent from 'dedent';
console.log(dedent`A string that gets so long you need to break it over
multiple lines. Luckily dedent is here to keep it
readable without lots of spaces ending up in the string
itself.`);
console.log(dedent`
A string that gets so long you need to break it over
multiple lines. Luckily dedent is here to keep it
readable without lots of spaces ending up in the string
itself.
`);
A string that gets so long you need to break it over
multiple lines. Luckily dedent is here to keep it
readable without lots of spaces ending up in the string
itself.
console.log(dedent`
Leading and trailing lines will be trimmed, so you can write something like
this and have it work as you expect:
* how convenient it is
* that I can use an indented list
- and still have it do the right thing
That's all.
`);
Leading and trailing lines will be trimmed, so you can write something like
this and have it work as you expect:
* how convenient it is
* that I can use an indented list
- and still have it do the right thing
That's all.
console.log(dedent`
Also works fine
${1}. With any kind of
${2}. Placeholders
`);
Also works fine
1. With any kind of
2. Placeholders
console.log(dedent(`
Wait! I lied. Dedent can also be used as a function.
`);
Wait! I lied. Dedent can also be used as a function.
MIT
See history for more details.
1.2.0
2020-09-28 Updated dependencies and a couple of minor improvments1.1.0
2019-07-26 Updated dependencies and fixed links in readme1.0.0
2018-06-14 Initial releasev1.2.0
Security update with dependency changes
FAQs
TypeScript package which smartly trims and strips indentation from multi-line strings
The npm package ts-dedent receives a total of 4,403,649 weekly downloads. As such, ts-dedent popularity was classified as popular.
We found that ts-dedent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.